Welcome Guest | Sign in | Register
.NET Programming Concepts - DotNet Programming Interview Questions and Answers | LucentBlackBoard | LucentBlackBoard.com

Home > Technical Interviews > Computer Science & Engineering > DotNet Programming > .NET Programming Concepts Questions and Answers

11. Briefly explain the characteristics of value-type variables that are supported in the C# programming language.

The variables that are based on value types directly contain values. The characteristics of value-type variables that are supported in C# programming language are as follows:
• All value-type variables derive implicitly from the System.ValueType class
• You cannot derive any new type from a value type
• Value types have an implicit default constructor that initializes the default value of that type
• The value type consists of two main categories:
• Structs - Summarizes small groups of related variables.
• Enumerations - Consists of a set of named constants.

12. Give the syntax of using the while loop in a C# program.

The syntax of using the while loop in C# is:
while(condition) //condition
{
//statements
}
You can find an example of using the while loop in C#:
int i = 0;
while(i < 5)
{
Console.WriteLine("{0} ", i);
i++;
}

13. What is a parameter? Explain the new types of parameters introduced in C# 4.0.

A parameter is a special kind of variable, which is used in a function to provide a piece of information or input to a caller function. These inputs are called arguments. In C#, the different types of parameters are as follows:
• Value type - Refers that you do not need to provide any keyword with a parameter.
• Reference type - Refers that you need to mention the ref keyword with a parameter.
• Output type - Refers that you need to mention the out keyword with a parameter.
• Optional parameter - Refers to the new parameter introduced in C# 4.0. It allows you to neglect the parameters that have some predefined default values. The example of optional parameter is as follows:
• public int Sum(int a, int b, int c = 0, int d = 0); /* c and d is optional */
• Sum(10, 20); //10 + 20 + 0 + 0
• Sum(10, 20, 30); //10 + 20 + 30 + 0
• Sum(10, 20, 30, 40); //10 + 20 + 30 + 40
• Named parameter - Refers to the new parameter introduced in C# 4.0. Now you can provide arguments by name rather than position. The example of the named parameter is as follows:
• public void CreateAccount(string name, string address = "unknown", int age = 0);
• CreateAccount("Sara", age: 30);
• CreateAccount(address: "India", name: "Sara");

14. Briefly explain the characteristics of reference-type variables that are supported in the C# programming language.

The variables that are based on reference types store references to the actual data. The keywords that are used to declare reference types are:
1. Class - Refers to the primary building block for the programs, which is used to encapsulate variables and methods into a single unit.
2. Interface - Contains only the signatures of methods, properties, events, or indexers.
3. Delegate - Refers to a reference type that is used to encapsulate a named or anonymous method.

15. What are the different types of literals?

A literal is a textual representation of a particular value of a type.

The different types of literals in Visual Basic are:
• Boolean Literals - Refers to the True and False literals that map to the true and false state, respectively.
• Integer Literals - Refers to literals that can be decimal (base 10), hexadecimal (base 16), or octal (base 8).
• Floating-Point Literals - Refers to an integer literal followed by an optional decimal point By default, a floating-point literal is of type Double.
• String Literals - Refers to a sequence of zero or more Unicode characters beginning and ending with an ASCII double-quote character.
• Character Literals - Represents a single Unicode character of the Char type.
• Date Literals - Represents time expressed as a value of the Date type.
• Nothing - Refers to a literal that does not have a type and is convertible to all types in the type system.

The different types of literals in C# are:
• Boolean literals - Refers to the True and False literals that map to the true and false states, respectively.
• Integer literals - Refers to literals that are used to write values of types int, uint, long, and ulong.
• Real literals - Refers to literals that are used to write values of types float, double, and decimal.
• Character literals - Represents a single character that usually consists of a character in quotes, such as 'a'.
• String literals - Refers to string literals, which can be of two types in C#:
• A regular string literal consists of zero or more characters enclosed in double quotes, such as "hello".
• A verbatim string literal consists of the @ character followed by a double-quote character, such as @"hello".

• The Null literal - Represents the null-type.




Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved © 2012-2015 SoftLucent.